package com.lantosec.hmrp.modules.monitor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lantosec.hmrp.core.util.MonitorUtils;
import com.lantosec.hmrp.modules.monitor.entity.SatisfactionEntity;
import com.lantosec.hmrp.modules.monitor.mapper.MonitorSatisfactionMapper;
import com.lantosec.hmrp.modules.monitor.service.IMonitorSatisfactionService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

@Service()
@Primary
@Log4j2
@SuppressWarnings("all")
public class MonitorSatisfactionServiceImpl extends ServiceImpl<MonitorSatisfactionMapper, SatisfactionEntity> implements IMonitorSatisfactionService {
    /***
     * 患者满意度 服务单元汇总数据，默认展示上个月数据
     */
    @Override
    public List<SatisfactionEntity> getServiceUnitsTotal(String month, String year) {
        String startTime = MonitorUtils.getLastMonth();
        List<SatisfactionEntity> param = null;
        if(StringUtils.isNotEmpty(month)){
            param = baseMapper.getMonthData(month);
        }else if(StringUtils.isNotEmpty(year)){
            param = baseMapper.getYearData(year);
        }else{
            param = baseMapper.getMonthData(startTime);
        }
        return param;
    }

    /***
     * 患者满意度 服务单元明细数据
     */
    @Override
    public List<SatisfactionEntity> getServiceUnitsDetails(String month, String year, String orgId) {
        List<SatisfactionEntity> param = null;
        if(StringUtils.isNotEmpty(month)){
            param = baseMapper.getMonthDataDetails(month,orgId);
        }else{
            param = baseMapper.getYearDataDetails(year,orgId);
        }
        return param;
    }

    @Override
    public List<SatisfactionEntity> getServiceWindowTotal(String month, String year) {
        String startTime = MonitorUtils.getLastMonth();
        List<SatisfactionEntity> param = null;
        if(StringUtils.isNotEmpty(month)){
            param = baseMapper.getWindowMonthData(month);
        }else if(StringUtils.isNotEmpty(year)){
            param = baseMapper.getWindowYearData(year);
        }else{
            param = baseMapper.getWindowMonthData(startTime);
        }
        return param;
    }

    @Override
    public List<SatisfactionEntity> getServiceWindowDetails(String month, String year, String userId) {
        List<SatisfactionEntity> param = null;
        if(StringUtils.isNotEmpty(month)){
            param = baseMapper.getWindowMonthDataDetails(month,userId);
        }else{
            param = baseMapper.getWindowYearDataDetails(year,userId);
        }
        return param;
    }
}
